<template>
    <div style="width:100%">
        <!-- 查询表单 -->
<el-form :inline="true" :model="formInline" class="demo-form-inline">
  <el-form-item label="楼盘名称">
    <el-input v-model="formInline.hname" placeholder="楼盘名称"></el-input>
  </el-form-item>


  <el-form-item>
    <el-button type="primary" @click="onSubmit">查询</el-button>
  </el-form-item>
</el-form>

<!-- 楼盘列表 -->
         <el-table
      :data="buildList"
      style="width: 100%"
      @row-click="detail"
    >
     
            <el-table-column align="center" label="序号"  
            type="index" width="180">
            </el-table-column>
            <el-table-column
        prop="hid"
        label="楼盘id"
        width="180">
      </el-table-column>
      <el-table-column
        prop="hname"
        label="项目名称"
        width="180">
      </el-table-column>
      <el-table-column
        prop="housestatus"
        label="楼盘状态"
        width="180">
      </el-table-column>
    </el-table>
      <!-- 分页 -->
			<div class="page-box">
				<el-pagination background
					layout="total, prev, pager, next, sizes, jumper"
					:current-page.sync="pageNum"
					:page-size.sync="pageSize"
					:total="total"
					:page-sizes="[1, 10, 20, 30, 40, 50, 100]"
					@current-change="show"
					@size-change="show">
				</el-pagination>
			</div>



     <el-button type="primary" @click="add">添加楼盘</el-button>
    </div>
    
</template>

<script>
export default{
    name:'buildList',
    data(){
        return{
            buildList :null,
             pageNum : 0,
        pageSize : 5,
        total : null,
             formInline: {
          hname: '',
          region: ''
        }
        }
    },
    mounted () {
        this.show();
        this.getAllHouseStatus();
    },
    methods: {
        show(){
            var the = this;
            this.sa.ajax("/buildManager/listAll",
            {
               'pageNum' : the.pageNum, 
              'pageSize' : the.pageSize
            },
            function(data){
                the.buildList = data.data.data.list;
                  the.total = data.data.data.total;
              the.pageNum = data.data.data.pageNum;
              the.pageSize = data.data.data.pageSize;
            }.bind(this)
            )
        },
        detail(hid){
          
            console.log(hid.hid)
            var tab = {id: 'houseDetail', name: '楼盘详细信息', view: () => import('@/sa-view/WmtbuildManager/houseDetail.vue'), params: {hid: hid.hid} };
            this.sa_admin.showTab(tab);
        },
        search(hname){
            var the = this;
            this.sa.ajax("/buildManager/findByName",
            {
                'hname':hname
            },
            function(data){
                the.buildList = data.data;
            }.bind(this)
            )
        },
         onSubmit() {
        var the = this;
            this.sa.ajax("/buildManager/findByName",
            {
                'hname':the.formInline.hname
            },
            function(data){
                the.buildList = data.data;
            }.bind(this)
            )
      },
      getAllHouseStatus(){
          var the = this;
            this.sa.ajax("/buildManager/getAllHouseStatus",
           null,
            function(data){
                the.formInline.region = data.data;
            }.bind(this)
            )
      },
      add(){
           var tab = {id: 'addHouse', name: '添加楼盘', view: () => import('@/sa-view/WmtbuildManager/addHouse.vue'), };
            this.sa_admin.showTab(tab);
      }
    }
}
</script>
